package com.example.shushiyunsst.fragment.main.home.child.miner.sub

import android.os.Bundle
import android.view.View
import com.example.library_common.adapter.JssBaseViewHolder
import com.example.library_common.album.utils.Utils
import com.example.library_common.base.BaseFragmentEx
import com.example.library_common.base.SimpleListFragment
import com.example.library_common.bean.CommonBean
import com.example.shushiyunsst.R
import com.example.shushiyunsst.fragment.main.home.child.miner.bean.StartTransferBuyingSubBean
import com.example.shushiyunsst.fragment.main.home.child.miner.bean.StartTransferSellBean
import com.lxj.xpopup.XPopup
import ikidou.reflect.TypeBuilder
import java.lang.reflect.Type

/**
 * 星树交易(卖)
 * */
class StartTransferSellFragment : SimpleListFragment<StartTransferSellBean>(), StartTransferLab {

    override val title = R.string.start_transfer_sell_lab

    companion object {
        fun newInstance(): StartTransferSellFragment {
            val args = Bundle()
            val fragment = StartTransferSellFragment()
            fragment.arguments = args
            return fragment
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        isAddDividerItemDecoration=false
        isEnableLoadMore=false
        mSuperBackPressedSupport=false
    }

    override fun initView(view: View) {
        super.initView(view)
        mHeader.removeAllViews()
        addHeader(R.layout.start_transfer_sell_header_fragment)
        mAdapter.addChildClickViewIds(R.id.sell_on)
        mAdapter.setOnItemChildClickListener { adapter, view, position ->
            XPopup.Builder(_mActivity)
                .hasShadowBg(false)
                .asCustom(StartTransferSellPop(_mActivity))
                .show()
        }

    }

    override fun getItemLayout()= R.layout.start_transfer_sell_fragment

    override fun convertItem(helper: JssBaseViewHolder?, item: StartTransferSellBean?) {

    }

    override fun getListType(): Type {
        return TypeBuilder.newInstance(CommonBean::class.java)
            .beginSubType(List::class.java)
            .addTypeParam(StartTransferSellBean::class.java).endSubType().build()
    }

    override fun netRequest() {
        val jsonFromRaw = Utils.getJsonFromRaw(_mActivity, R.raw.temp_fack_data)
        parseDate(jsonFromRaw)
    }
}